package com.google.cbmgraph.cell;


import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
/**
 * This object holds the data for a cell, it is a flyweight object, 
 * only holding status and the bare minimums to draw it
 * 
 * @author lawlerr1
 *
 */
public class GraphCell {
	public int cellID = 0;
	public boolean vertConnect = false;
	private int cellStatus;
	private String annontation;
	private Paint paint = new Paint();
/**
 * Constructor
 * @param id
 */
	public GraphCell(int id){
		cellID = id;
		cellStatus = 99;
		annontation = "";
	}
	/**
	 * Constructor 
	 * @param id
	 * @param status
	 */
	public GraphCell(int id, int status){
		cellID = id;
		cellStatus = status;
		annontation = "";
	}
/**
 * Constructor
 * @param id
 * @param status
 * @param note
 */
	public GraphCell(int id, int status, String note){
		cellID = id;
		cellStatus = status;
		annontation = note;
	}
	/**
	 * accessor 
	 * @return status 
	 */
	public int getStatus(){
		return cellStatus;
	}
	/**
	 * Mutator
	 * @param newStatus
	 */
	public void changeStatus(int newStatus){
		cellStatus = newStatus;
	}
	/**
	 * Mutator
	 * @param note
	 */
	public void addNote(String note){
		annontation = note;
	}
	/**
	 * Accessor
	 * @return
	 */
	public String getNote(){
		return annontation;
	}
	/**
	 * sets if a point needs to be part of a connection
	 * @param conn
	 */
	public void Connected(boolean conn){
		vertConnect = conn;
	}
	/**
	 * draws the object on the canvas at a particular point
	 * @param canvas
	 * @param x
	 * @param y
	 */
	public void draw(Canvas canvas, int x, int y){
		paint.setColor(Color.DKGRAY);
		canvas.drawRect(x,y,x+CellFormat.X, y+CellFormat.Y, paint);
		paint.setColor(Color.BLACK);
		canvas.drawRect(x+1,y+1,x+CellFormat.X-1, y+CellFormat.Y-1, paint);
		if (vertConnect){
			paint=CellFormat.getCellColor(CellFormat.NODECELL);
			canvas.drawRect(x+CellFormat.X-5,y+1,x+CellFormat.X-1, y+CellFormat.Y-1, paint);	
		}
		paint=CellFormat.getCellColor(cellStatus);
		canvas.drawRect(x+1,y+3,x+CellFormat.X-1, y+6, paint);
	}
}
